/**
*      author: Y_Yao
*      created: 2025-04-23 10:15:57
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e3 + 7;
const int M = 4e4 + 7;
int v[N],w[N],dp[M];
int n,s;
int cnt = 1;

void solve()
{
    cin >> n >> s;
    for(int i = 1;i <= n;i++)
    {
        int x,y,z;
        cin >> x >> y >> z;
        for(int j = 1;j <= z;j <<= 1)
        {
            v[cnt] = j * x;
            w[cnt] = j * y;
            cnt++;
            z -= j; 
        }
        if(z != 0)
        {
            v[cnt] = z * x;
            w[cnt] = z * y;
            cnt++;
        }
    }

    for(int i = 1;i < cnt;i++)
    {
        for(int j = s;j >= w[i];j--)
        {
            dp[j] = max(dp[j],dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[s] << " ";
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}